import React, {useEffect, useState} from 'react';
import {queryRiskInfo, queryRiskList} from '@/axios/apis.ts'
import {useSearchParams} from 'react-router-dom'
import {Button, Row, Table} from "antd";
import {findDicNameForDicCode, getDicOnCode} from '@/utils/dicAll.ts'
import PageModule from '@/components/PageModule.tsx'
import CycleForm from "@/components/DynamicSearchForm/CycleForm.tsx";

const InsuranceInfo = () => {
    let [searchParams] = useSearchParams()
    let [dataSource, setDataSource] = useState<[]>([])
    const [formFields, setFormFields] = useState<Array<object>>([])
    const getInfo = () => {
        if (searchParams.get('productId')) {
            queryRiskList({productId: searchParams.get('productId')}).then(res => {
                if (+res.code === 200) {
                    setDataSource(res.data.records)
                }
            })

        }
    }

    const columns = [
        {
            title: '操作',
            key: 'action',
            render: (_, record) => (
                <div className="table-options">
                    <span className="operation_style" onClick={() => {
                        // navigate('/CarInsuranceDetails')
                    }}>明细</span>
                </div>
            ),
            width: 100
        },
        {
            title: "ID",
            dataIndex: "id",
            key: "id",
        },
        {
            title: "保险公司",
            dataIndex: "insuranceName",
            key: "insuranceName",
        },
        {
            title: "保险公司险种代码",
            dataIndex: "insurcanceRiskCode",
            key: "insurcanceRiskCode",
        },
        {
            title: "险种代码",
            dataIndex: "riskCode",
            key: "riskCode",
        },
        {
            title: "险种简称",
            dataIndex: "riskShortName",
            key: "riskShortName",
        }, {
            title: "状态",
            dataIndex: "status",
            key: "status",
            render: (value) => <>{findDicNameForDicCode('SYS.VALID', value)}</>,
        },
        {
            title: "创建人",
            dataIndex: "createUserName",
            key: "createUserName",
        },
        {
            title: "创建时间",
            dataIndex: "createTime",
            key: "createTime",
        }
    ]
    useEffect(() => {
        getInfo()
    }, []);
    return (
        <div>
            <Table
                dataSource={dataSource}
                columns={columns}
                rowKey="id"
                size="middle"
                bordered={true}
            />
        </div>
    );
};

export default InsuranceInfo;